import '../model/result_model.dart';
import '../model/school_teacher_model.dart';
import '../utils/request.dart';

///学校教师接口
class SchoolTeacherApi {
  SchoolTeacherApi._();

  static final _singlton = SchoolTeacherApi._();

  factory SchoolTeacherApi() => _singlton;

  ///查询
  Future<SchoolTeacherQueryRes> query(final SchoolTeacherQueryReq req) =>
      request
          .getHandler(
            path: '/school/${req.schoolId}/teacher',
            params: req.toMap(),
          )
          .then((res) => SchoolTeacherQueryRes.fromModel(res));

  ///加载
  Future<SchoolTeacherInfoRes> info(final String id) => request
      .getHandler(path: '/school/teacher/$id')
      .then((res) => SchoolTeacherInfoRes.fromModel(res));

  ///新增
  Future<BaseModelRes> add(final SchoolTeacherAddReq req) => request
      .postHandler(path: '/school/${req.schoolId}/teacher', data: req.toMap());

  ///修改
  Future<BaseModelRes> modify(final SchoolTeacherModifyReq req) =>
      request.putHandler(path: '/school/teacher/${req.id}', data: req.toMap());

  ///删除
  Future<BaseModelRes> delete(final String id) =>
      request.deleteHandler(path: '/school/teacher/$id');
}

//学校教师接口单例
final schoolTeacherApi = SchoolTeacherApi();
